<template>
    <!--设备统计-->
    <div class="right_equipment_statistics">
        <div class="equipment">
            <div class="equipment_num">
                <span>设备总数(个)</span>
                <span>28</span>
            </div>
            <div class="equipment_statistics_echarts">
                <chart-view :chart-option="state.equipmentStatistics" :auto-resize="true" height="105px"></chart-view>
            </div>
        </div>
        <div class="statistics">
            <div v-for="(item, index) in state.statisticsList" :key="index">
                <div>
                    <span :style="{ background: item.back }"></span>
                    <span>{{ item.name }}</span>
                </div>
                <div>
                    <span>{{ item.num }}</span>
                </div>
            </div>
        </div>
    </div>
</template>
<script lang="ts" setup>
import { reactive, onMounted, nextTick } from 'vue';
import { EchartsMethods } from '@/chart/index';

const datas = {
    alpha: 35,
    distance: 138,
    top: '-8%',
    pieData: 60,
    autoRotate: false,
    item: [
        {
            name: '在线',
            value: 37,
            itemStyle: {
                color: '#23FFFC'
            }
        },
        {
            name: '离线',
            value: 44,
            itemStyle: {
                color: '#CACACA'
            }
        },
        {
            name: '故障',
            value: 32,
            itemStyle: {
                color: '#FE3000'
            }
        },
        {
            name: '未激活',
            value: 16,
            itemStyle: {
                color: '#FFDA30'
            }
        }
    ]
};
const state = reactive({
    statisticsList: [
        {
            back: '#23FFFC',
            name: '在线',
            num: '1271'
        },
        {
            back: '#CACACA',
            name: '离线',
            num: '1271'
        },
        {
            back: '#FE3000',
            name: '故障',
            num: '20'
        },
        {
            back: '#FFDA30',
            name: '未激活',
            num: '20'
        }
    ],
    equipmentStatistics: {}
});

onMounted(() => {
    nextTick(() => {
        state.equipmentStatistics = EchartsMethods.equipmentStatistics(datas);
    });
});
</script>

<style scoped lang="scss">
.right_equipment_statistics {
    display: flex;
    height: 90%;
    .equipment {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: 160px;
        > div {
            width: 100%;
        }
    }
    .equipment_num {
        margin-top: 4px;
        height: 25%;
        background: url(@/assets/image/equipmentnumback.png) no-repeat;
        background-size: 100% 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-left: 10px;

        span {
            display: inline-block;

            &:nth-of-type(1) {
                font-size: 12px;
                font-weight: 500;
                color: #ffffff;
                width: 60%;
            }
            &:nth-of-type(2) {
                font-size: 18px;
                font-family: Source Han Sans CN;
                font-weight: bold;
                color: #23fffc;
                text-align: center;
                width: 40%;
            }
        }
    }
    .equipment_statistics_echarts {
        height: 60%;
    }

    .statistics {
        display: flex;
        flex-wrap: wrap;
        width: 158px;
        margin-left: 20px;
        padding-top: 8px;
        align-content: flex-start;
        > div {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            height: 24px;
            padding: 0 12px;
            margin-bottom: 6px;
            background: url(@/assets/image/equipmentStatisticsback.png) no-repeat;
            background-size: 100% 100%;
            position: relative;
            div {
                &:nth-of-type(1) {
                    width: 60%;
                    span {
                        display: inline-block;
                        &:nth-of-type(1) {
                            width: 10px;
                            height: 10px;
                            border-radius: 5px;
                            margin-right: 13px;
                        }
                        &:nth-of-type(2) {
                            font-size: 11px;
                            font-family: Source Han Sans CN;
                            color: #b4c1bf;
                        }
                    }
                }
                &:nth-of-type(2) {
                    width: 40%;
                    padding-left: 15px;
                    span {
                        display: inline-block;
                        width: 100%;
                        font-size: 16px;
                        font-family: PangMenZhengDao;
                        color: #23fffc;
                        text-align: left;
                    }
                }
            }

            &:nth-of-type(1) {
                margin-top: 12px;
            }
        }
    }
}
</style>
